<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
    String path = request.getContextPath();

    String basePath = request.getScheme() + "://" + request.getServerName() + ":"
                      + request.getServerPort() + path + "/";
    //<script type="text/javascript"
	//src="/js/easyui/jquery-1.7.2.min.js"></script>
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>编辑用户</title>
<s:include value="../include.jsp"></s:include>
<link rel="stylesheet" type="text/css" href="../css/ztree/demo.css">
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>css/ztree/zTreeStyle/zTreeStyle.css">
<script type="text/javascript"
	src="<%=basePath%>js/ztree/jquery.ztree.core-3.3.js"></script>

<script type="text/javascript">	


	/**
	 * 保存
	 */
	function save() {
		var password = document.getElementById("password");
		var test_password = document.getElementById("test_password");
		var ensurePassword = document.getElementById("ensurePassword");
		var test_ensurePassword = document.getElementById("test_ensurePassword");
		var name = document.getElementById("userName");
		var test_name = document.getElementById("test_name");
		
		test_password.style.display = "none";
		test_ensurePassword.style.display = "none";
		test_name.style.display = "none";
	
	    var returnInfo;
    
  	
    
		
		
		if(password.value.length < 6)
		{
			test_password.style.display = "block";
			password.value = "";
	//		password.focus();
			returnInfo = false;
		}
		if(ensurePassword.value != password.value)
		{
			test_ensurePassword.style.display = "block";
			ensurePassword.value = "";
	//		ensurePassword.focus();
			returnInfo = false;
		}
		if(name.value == "")
		{
			test_name.style.display = "block";
			name.value = "";
	//		name.focus();
			returnInfo = false;
		}
		if(returnInfo == false)
		{
			return returnInfo;
		}
	
		/*
		//检验
		var lName = document.getElementById("loginName").value;
		lName = trimVal(lName);
		if (lName == "") {
			alert("登录名是必填项");
			return;
		}
		var uName = document.getElementById("userName").value;
		uName = trimVal(uName);
		if (uName == "") {
			alert("用户名是必填项");
			return;
		}
		var pw = document.getElementById("password").value;
		pw = trimVal(pw);
		if (pw == "") {
			alert("密码是必填项");
			return;
		}
		*/
		
		chgAction("userAction", "update");
		document.forms[0].submit();
	}
	
	

	/**
	 * 返回
	 */
	function back() {
		window.location = "userAction.action";
	}
	<s:if test="operateResult=='suc'">
	alert("保存成功");
	window.location = "userAction!query.action";
	</s:if>
	<s:elseif test="operateResult=='fail'">
	alert("保存失败");
	</s:elseif>
</script>
</head>
<body>
	<div class="outerDiv" style="height:500px;overflow-y: auto;">
		<s:form name="form1" action="userAction" method="post">
			<div class="top_box">
				您的位置：系统用户管理&gt;&gt;<span class="red">编辑用户</span>
			</div>
			
			<div class="form_list_box">
				<table width="100%">
					<tr>
						<td align="right" width="40%"><font color="red">*</font>登录名：</td>
						<td align="left"><font color="red" size="3"><s:property value="userInfo.loginName" /></font>
						</td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>密&nbsp;&nbsp;&nbsp;&nbsp;码：</td>
						<td align="left"><s:password name="userInfo.password"
								id="password" maxlength="25"></s:password>
						</td>
						<td width="524"><div id="test_password" style="display:none;text-align:left;"><font color="#FF0000">密码不能小于6位</font></div></td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>确认密码：</td>
						<td align="left"><s:password name="ensurePassword"
								id="ensurePassword" maxlength="25"></s:password>
						</td>
						<td><div id="test_ensurePassword" style="display:none;text-align:left;"><font color="#FF0000">两次输入密码不相同</font></div></td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>用户名：</td>
						<td align="left"><s:textfield name="userInfo.userName"
								id="userName" maxlength="25"></s:textfield>
						</td>
						<td height="24"><div id="test_name" style="display:none;text-align:left;"><font color="#FF0000">用户名不能为空</font></div></td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>角&nbsp;&nbsp;&nbsp;&nbsp;色：</td>
						<td align="left"><select name="userInfo.roleId" id="roleName" style="width: 150px">
				      	<s:iterator value="roleList" id="roleList" status="st">
				        <option value="<s:property value="roleId" />"><s:property value="roleName" /></option>
				        </s:iterator>
				      </select></td>
					</tr>
					<script>
					$("#roleName").val('<s:property value="userInfo.roleId"/>');
					$("#password").val('<s:property value="userInfo.password"/>');
					$("#ensurePassword").val('<s:property value="userInfo.password"/>');
					</script>
				</table>
				<div class="btn_box">
					<a href="#" onclick="save()"><s></s>保存</a> <a href="#"
						onclick="back()"><s></s>返回</a>
				</div>
			</div>
		</s:form>
	</div>
</body>
</html>